﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Administracija.master" AutoEventWireup="true" CodeFile="AdministracijaSlika.aspx.cs" Inherits="AdministracijaSlika" ValidateRequest="false" %>

<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <link href="Stilovi/AdministracijaSlika.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <div id="administracijaMeni">
                 <ul class="meni_lista">
                    <li><a href="Administracija.aspx">Administracija naslovna</a></li>
                    <li><a href="AdministracijaClanaka.aspx">Administracija članaka</a></li>
                    <li><a href="AdministracijaDrveca.aspx">Administracija drveća</a></li>
                    <li><a href="AdministracijaRasadnika.aspx">Administracija rasadnika</a></li>
                 </ul>
     </div>

     <div id="glavni">

     <!---------------------Administriranje galerija-------------------------------------------->
         <h2>Administracija galerija</h2>
         <div id="galerije">
         <div id="porukaGalerije" runat="server">
         </div>
             <asp:SqlDataSource ID="sdsGalerija" runat="server" 
                 ConnectionString="<%$ ConnectionStrings:EnciklopedijaDrvecaConnectionString %>" 
                 DeleteCommand="DELETE FROM [Galerija] WHERE [GalerijaID] = @GalerijaID" 
                 InsertCommand="INSERT INTO [Galerija] ([NazivGalerije]) VALUES (@NazivGalerije)" 
                 SelectCommand="SELECT * FROM [Galerija]" 
                 UpdateCommand="UPDATE [Galerija] SET [NazivGalerije] = @NazivGalerije WHERE [GalerijaID] = @GalerijaID">
                 <DeleteParameters>
                     <asp:Parameter Name="GalerijaID" Type="Int32" />
                 </DeleteParameters>
                 <InsertParameters>
                     <asp:Parameter Name="NazivGalerije" Type="String" />
                 </InsertParameters>
                 <UpdateParameters>
                     <asp:Parameter Name="NazivGalerije" Type="String" />
                     <asp:Parameter Name="GalerijaID" Type="Int32" />
                 </UpdateParameters>
             </asp:SqlDataSource>
             <asp:GridView ID="grdGalerija" runat="server" AllowPaging="True" 
                 AutoGenerateColumns="False" DataKeyNames="GalerijaID" 
                 DataSourceID="sdsGalerija" onrowcommand="grdGalerija_RowCommand" 
                 onselectedindexchanged="grdGalerija_SelectedIndexChanged" 
                 BackColor="#000066" ForeColor="White" CellPadding="10">
                 <AlternatingRowStyle BackColor="#000099" ForeColor="White" />
                 <Columns>
                     <asp:CommandField 
                         ShowSelectButton="True" CausesValidation="False" CancelText="Odustani" 
                         DeleteText="Izbriši" EditText="Uredi" InsertText="Dodaj" NewText="Novo" 
                         SelectText="Odaberi" UpdateText="Uredi" >
                     <ItemStyle Font-Bold="True" ForeColor="White" />
                     </asp:CommandField>
                     <asp:BoundField DataField="GalerijaID" HeaderText="Id galerije" 
                         InsertVisible="False" ReadOnly="True" SortExpression="GalerijaID" />
                     <asp:BoundField DataField="NazivGalerije" HeaderText="Naziv galerije" 
                         SortExpression="NazivGalerije" />
                     <asp:TemplateField HeaderText="Brisanje slika sa diska">
                         <ItemTemplate>
                             <asp:CheckBox id="CheckBox1" runat="server" Text="Da/Ne" />
                         </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Brisanje">
                         <ItemTemplate >
                             <asp:Button CommandName="btnBrisiGaleriju" ID="Button1" runat="server" 
                                 Height="28px" onclick="Button1_Click" 
                                 Text="Briši" Width="114px" 
                                 CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' 
                                 CausesValidation="False" />
                            
                         </ItemTemplate>
                     </asp:TemplateField>
                 </Columns>
                 <HeaderStyle BackColor="Black" BorderStyle="Solid" BorderWidth="2px" />
                 <SelectedRowStyle BackColor="#006600" ForeColor="Black" />
             </asp:GridView>
             <asp:SqlDataSource ID="sdsgalerijaThumbnails" runat="server" 
                 ConnectionString="<%$ ConnectionStrings:EnciklopedijaDrvecaConnectionString %>" 
                 DeleteCommand="DELETE FROM [Thumbnail] WHERE [ThumbnailID] = @ThumbnailID" 
                 InsertCommand="INSERT INTO [Thumbnail] ([NazivThumbnaila], [Link], [LinkNaVelikuSliku], [Sirina], [DodatniHtml], [Visina], [GalerijaID]) VALUES (@NazivThumbnaila, @Link, @LinkNaVelikuSliku, @Sirina, @DodatniHtml, @Visina, @GalerijaID)" 
                 SelectCommand="SELECT * FROM [Thumbnail] WHERE ([GalerijaID] = @GalerijaID)" 
                 UpdateCommand="UPDATE [Thumbnail] SET [NazivThumbnaila] = @NazivThumbnaila, [Link] = @Link, [LinkNaVelikuSliku] = @LinkNaVelikuSliku, [Sirina] = @Sirina, [DodatniHtml] = @DodatniHtml, [Visina] = @Visina, [GalerijaID] = @GalerijaID WHERE [ThumbnailID] = @ThumbnailID">
                 <DeleteParameters>
                     <asp:Parameter Name="ThumbnailID" Type="Int32" />
                 </DeleteParameters>
                 <InsertParameters>
                     <asp:Parameter Name="NazivThumbnaila" Type="String" />
                     <asp:Parameter Name="Link" Type="String" />
                     <asp:Parameter Name="LinkNaVelikuSliku" Type="String" />
                     <asp:Parameter Name="Sirina" Type="Int32" />
                     <asp:Parameter Name="DodatniHtml" Type="String" />
                     <asp:Parameter Name="Visina" Type="Int32" />
                     <asp:Parameter Name="GalerijaID" Type="Int32" />
                 </InsertParameters>
                 <SelectParameters>
                     <asp:ControlParameter ControlID="grdGalerija" Name="GalerijaID" 
                         PropertyName="SelectedValue" Type="Int32" />
                 </SelectParameters>
                 <UpdateParameters>
                     <asp:Parameter Name="NazivThumbnaila" Type="String" />
                     <asp:Parameter Name="Link" Type="String" />
                     <asp:Parameter Name="LinkNaVelikuSliku" Type="String" />
                     <asp:Parameter Name="Sirina" Type="Int32" />
                     <asp:Parameter Name="DodatniHtml" Type="String" />
                     <asp:Parameter Name="Visina" Type="Int32" />
                     <asp:Parameter Name="GalerijaID" Type="Int32" />
                     <asp:Parameter Name="ThumbnailID" Type="Int32" />
                 </UpdateParameters>
             </asp:SqlDataSource>
             <asp:GridView ID="grdDetaljiGalerija" runat="server" AllowPaging="True" 
                 AllowSorting="True" DataSourceID="sdsgalerijaThumbnails" 
                 BackColor="#000066" ForeColor="White" CellPadding="10" 
                 AutoGenerateColumns="False" DataKeyNames="ThumbnailID">
                 <AlternatingRowStyle BackColor="#003399" ForeColor="White" />
                 <Columns>
                     <asp:CommandField CancelText="Odustani" DeleteText="Izbriši" EditText="Uredi" 
                         InsertText="Dodaj" NewText="Novo" SelectText="Odaberi" ShowDeleteButton="True" 
                         ShowEditButton="True" UpdateText="Potvrdi" />
                     <asp:BoundField DataField="ThumbnailID" HeaderText="Thumbnail ID" 
                         InsertVisible="False" ReadOnly="True" SortExpression="ThumbnailID" />
                     <asp:BoundField DataField="NazivThumbnaila" HeaderText="Naziv thumbnaila" 
                         SortExpression="NazivThumbnaila" />
                     <asp:BoundField DataField="Link" HeaderText="Link" SortExpression="Link" />
                     <asp:BoundField DataField="LinkNaVelikuSliku" HeaderText="Link na veliku sliku" 
                         SortExpression="LinkNaVelikuSliku" />
                     <asp:BoundField DataField="Sirina" HeaderText="Širina" 
                         SortExpression="Sirina" />
                     <asp:BoundField DataField="DodatniHtml" HeaderText="Opis" 
                         SortExpression="DodatniHtml" />
                     <asp:BoundField DataField="Visina" HeaderText="Visina" 
                         SortExpression="Visina" />
                     <asp:BoundField DataField="GalerijaID" HeaderText="Galerija ID" 
                         SortExpression="GalerijaID" />
                 </Columns>
                 <HeaderStyle BackColor="Black" BorderStyle="Solid" BorderWidth="2px" />
                 <SelectedRowStyle BackColor="#006600" ForeColor="Black" />
             </asp:GridView>
             <br />

             <div id="dodavanjeGalerije">
                 <asp:Label id="lblDodajGaleriju" runat="server" Text="Dodaj galeriju : "></asp:Label>
                 <br />
                 <asp:TextBox id="txtDodajGaleriju" runat="server"></asp:TextBox>
                 <asp:Button ID="btnDodajGaleriju" runat="server" Text="Dodaj u bazu" 
                     onclick="btnDodajGaleriju_Click" ValidationGroup="galerija" />

                 <asp:RequiredFieldValidator ID="validacijaGalerija" runat="server" 
                     ControlToValidate="txtDodajGaleriju" 
                     ErrorMessage="Potrebno je unijeti ime galerije" ForeColor="Red" 
                     ValidationGroup="galerija"></asp:RequiredFieldValidator>

             </div>
         </div>

           <!---------------------Administriranje slika-------------------------------------------->

           <h2>Administracija  slika</h2>
           <div id="slike">
           <h3>Dodavanje thumbnailova i slika</h3>
           <div id="porukaODodavanju" runat="server"></div>
                <div id="dodajThumb">
                    <asp:Label id="lblDodajThumb" runat="server" Text="Dodavanje thumbnaila : "></asp:Label>
                    <br />
                    <asp:FileUpload ID="FileUpload1" runat="server" />
                    <asp:RequiredFieldValidator ID="validacijaThumbFileUpload" runat="server" 
                        ControlToValidate="FileUpload1" 
                        ErrorMessage="Potrebno je unijeti stazu do fizičke lokacije thumbnaila" 
                        ForeColor="Red" ValidationGroup="thumb"></asp:RequiredFieldValidator>
                </div>
                <div id="dodajVelikuSliku">
                    <asp:Label id="lblDOdajVelikuSliku" runat="server" Text="Dodavanje velike slike : "></asp:Label>
                    <br />
                    <asp:FileUpload ID="FileUpload2" runat="server" />
                </div>

                <div id="nazivGalerije">
                    <asp:Label id="lblOdaberiNazivGalerije" runat="server" Text="Odaberite naziv galerije (Galerija mora biti kreirana u bazi) : "></asp:Label>
                    <br />
                    <asp:SqlDataSource ID="sdsDodajThumbGalerije" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:EnciklopedijaDrvecaConnectionString %>" 
                        SelectCommand="SELECT * FROM [Galerija]"></asp:SqlDataSource>
                    <asp:DropDownList ID="ddlNazivGalerije" runat="server" 
                        DataSourceID="sdsDodajThumbGalerije" DataTextField="NazivGalerije" 
                        DataValueField="GalerijaID"></asp:DropDownList>
                </div>

                <div id="dimenzije">
                     <asp:Label id="lblSirina" runat="server" Text="Upišite širinu thumbnaila : "></asp:Label>
                    <br />
                    <asp:TextBox id="txtSirinaThumbnaila" runat="server"></asp:TextBox>
                     <asp:RequiredFieldValidator ID="validacijaSirinaThumbnaila" runat="server" 
                         ControlToValidate="txtSirinaThumbnaila" 
                         ErrorMessage="Unesite širinu thumbnaila u pikselima" ForeColor="Red" 
                         ValidationGroup="thumb"></asp:RequiredFieldValidator>
                    <br />
                     <asp:Label id="lblVisina" runat="server" Text="Upišite visinu thumbnaila : "></asp:Label>
                    <br />
                    <asp:TextBox id="txtVisinaThumbnaila" runat="server"></asp:TextBox>
                     <asp:RequiredFieldValidator ID="validacijaVisineThumbnaila" runat="server" 
                         ControlToValidate="txtVisinaThumbnaila" 
                         ErrorMessage="Unesite visinu thumbnaila u pikselima" ForeColor="Red" 
                         ValidationGroup="thumb"></asp:RequiredFieldValidator>
                </div>

                <div id="dodatniHtml">
                    <asp:Label id="lblDodatniHtml" runat="server" Text="Upišite dodatne informacije uz thumbnail : "></asp:Label>
                    <br />
                    <CKEditor:CKEditorControl ID="ftbOpisThumbnaila" runat="server" ClientIDMode="Static" ></CKEditor:CKEditorControl>

                </div>
                <span> 
               <asp:Button id="btnDodaj" runat="server" Text="Dodaj u bazu" 
                   onclick="btnDodaj_Click" ValidationGroup="thumb" /></span>
                <span> <asp:Button id="btnOdustani" runat="server" Text="Odustani" 
                   onclick="btnOdustani_Click" CausesValidation="false" /></span>
               
           </div>

             <!---------------------Administriranje slika-------------------------------------------->
     </div>
</asp:Content>

